#pragma once

#include <vector>
#include <string>
#include <set>
#include <map>
#include <cstdint>

enum class LaserDirection
{
    Left,
    Right,
    Up,
    Down,
};

using Position = std::pair<std::int64_t, std::int64_t>;

class Contraption
{
public:
    Contraption(const std::string& filepath);

    std::size_t routing(const Position& begin = {0, 0}, LaserDirection direction = LaserDirection::Right) const;
    std::size_t maxRouting() const;

private:
    void doRouting(
         const Position& begin, 
         LaserDirection direction, 
         std::map<Position, std::vector<LaserDirection>>& passed) const;

    char character(const Position& pos) const;
    bool invalid(const Position& pos) const;
    bool invalidRow(std::int64_t row) const;
    bool invalidCol(std::int64_t col) const;

private:
    std::vector<std::string> _data;
};